<template>
    <div>
        <el-table :data="tableData">
          <el-table-column label="用户名" prop="name"></el-table-column>
          <el-table-column label="性别" prop="sex"></el-table-column>
          <el-table-column label="地址" prop="addr"></el-table-column>
          <el-table-column label="爱好" prop="hobby"></el-table-column>
        </el-table>

        <el-button type="primary" @click="getMessage">查询</el-button>
    </div>
</template>
<script>
import axios from 'axios'
export default {
    name: 'Second',
    data() {
        return {
            tableData:[]
        }
    },
    methods: {
        getMessage() {
            axios.get('http://localhost:8083/getUser', {
                headers: {
                    'Content-Type': 'application/json;charset=UTF-8',//设置请求头请求格式为JSON
                },
            }).then(
                (res) => {
                    console.log("用户数据", res.data);
                      this.tableData = res.data;
                }
            )
        }
    }
}

</script>
<style>
</style>